Skip to content

fix(waste_identification_ml): correct logger.exception calls in inference_pipeline#13635

Closed
Bojun-Vvibe wants to merge 1 commit intotensorflow:masterfrom
Bojun-Vvibe:agent/tensorflow_models-1776829391
Closed

fix(waste_identification_ml): correct logger.exception calls in inference_pipeline#13635
Bojun-Vvibe wants to merge 1 commit intotensorflow:masterfrom
Bojun-Vvibe:agent/tensorflow_models-1776829391

Conversation

@Bojun-Vvibe
Copy link
Copy Markdown

Repo: tensorflow/models (⭐ 77668)
Type: bugfix
Files changed: 1
Lines: +7/-7

What

Fixes four misuses of logger.exception() in official/projects/waste_identification_ml/Triton_TF_Cloud_Deployment/client/inference_pipeline.py. Each call passed the bound exception variable e as an extra positional arg (logger.exception("Exception occured:", e)), which the logging module treats as a format arg — not as traceback information — and which can raise a formatting error. The final call in the cropping block referenced e despite its except clause not binding a name, which would raise NameError if that branch ever executed. All four sites are now logger.exception("Exception occurred."), and the unused as e bindings are dropped. Also corrects the misspelling "occured" → "occurred".

Why

logger.exception automatically attaches the current exception's traceback (it's equivalent to logger.error(..., exc_info=True)). Passing the exception object as a second arg is both redundant and incorrect: the message contains no %s, so logging tries to format with a stray arg. More seriously, the cropping block's handler (except (...) : with no as e) references an undefined e, so a genuine failure there turns into a NameError that masks the original error.

Testing

  • python3 -m py_compile / ast.parse on the modified file: passes.
  • Manual inspection of all four except blocks: each now uses logger.exception with a plain message; the bound name is removed where it is no longer needed.
  • No behavior change on the happy path; error paths now log the real traceback instead of crashing on a NameError/format mismatch.

Risk

Low — change is confined to four except blocks inside one file; purely corrects error-logging calls and a typo, no control-flow change.

…ence_pipeline

logger.exception() already captures the current exception and does not
accept extra positional args for the exception object. The prior calls
passed an 'e' variable as an extra arg, which would be appended to the
log record args rather than used for the traceback. Additionally, the
cropping block's except clause bound no name but still referenced 'e',
which would raise NameError if that path executed.

Also fixes the spelling (occured -> occurred) in the log messages.
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 22, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Bojun-Vvibe
Copy link
Copy Markdown
Author

Closing — unable to sign the project's CLA from this account. Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants